//
//  Const.h
//  YuDing
//
//  Created by MT on 2017/7/29.
//  Copyright © 2017年 MT. All rights reserved.
//

#ifndef Const_h
#define Const_h

#ifdef DEBUG
    #define DebugLog(fmt, ...)  NSLog(fmt, ##__VA_ARGS__)
    #define kInDeveloping 1
#else
    #define DebugLog(fmt, ...)  /* */
    #define kInDeveloping 0
#endif

//常用工具宏
#define SCREEN_WIDTH ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)]?[UIScreen mainScreen].nativeBounds.size.width/[UIScreen mainScreen].nativeScale:[UIScreen mainScreen].bounds.size.width)

#define SCREEN_HEIGHT ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)]?[UIScreen mainScreen].nativeBounds.size.height/[UIScreen mainScreen].nativeScale:[UIScreen mainScreen].bounds.size.height)

#define SCREEN_RATE (375/[UIScreen mainScreen].bounds.size.width)
/** ->View 圆角和加边框 */
#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

/** ->View 圆角 */
#define ViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]

#define TabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:44) //底部tabbar高度
#define TopHeight ((iPhoneX || IPHONE_Xr || IPHONE_Xs || IPHONE_Xs_Max) ? 88.0 : 64.0)
#define iPhoneXHeightPoor ((iPhoneX || IPHONE_Xr || IPHONE_Xs || IPHONE_Xs_Max) ? 24.0 : 0.0)
#define iPhoneXTabBarHeightPoor ((iPhoneX || IPHONE_Xr || IPHONE_Xs || IPHONE_Xs_Max) ? 37.0 : 0.0)

#define ColorWithRGB(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]

// weakself
#define WeakSelf __weak typeof(self)weakSelf = self
//判断是否是iPhoneX,iPHoneXr,iPhoneXs Max
#define WYFIphoneX (CGSizeEqualToSize(CGSizeMake(375.f, 812.f), [UIScreen mainScreen].bounds.size) || CGSizeEqualToSize(CGSizeMake(812.f, 375.f), [UIScreen mainScreen].bounds.size) || CGSizeEqualToSize(CGSizeMake(414.f, 896.f), [UIScreen mainScreen].bounds.size) || CGSizeEqualToSize(CGSizeMake(896.f, 414.f), [UIScreen mainScreen].bounds.size))
//判断是否是ipad
#define isPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
//判断iPhoneX
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPHoneXr
#define IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPhoneXs
#define IPHONE_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iPhoneXs Max
#define IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhoneNormal ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhonePlus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

#define PushNotice(noticename,sendobject)  [[NSNotificationCenter defaultCenter]postNotificationName:noticename object:sendobject];

#define AddBotice(select,noticename) [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(select:) name:noticename object:nil];

#define RemoveNotice(noticename) [[NSNotificationCenter defaultCenter]removeObserver:self name:noticename object:nil];

#define URLSPL(url1,url2) [NSString stringWithFormat:@"%@%@",url1,url2]

#define UrlDeal(url) ([url hasPrefix:@"http"]?url:[NSString stringWithFormat:@"%@%@",currentUrl,url])

#define AppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

#define  adjustsScrollViewInsets(scrollView)\
do {\
_Pragma("clang diagnostic push")\
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"")\
if ([scrollView respondsToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
NSMethodSignature *signature = [UIScrollView instanceMethodSignatureForSelector:@selector(setContentInsetAdjustmentBehavior:)];\
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];\
NSInteger argument = 2;\
invocation.target = scrollView;\
invocation.selector = @selector(setContentInsetAdjustmentBehavior:);\
[invocation setArgument:&argument atIndex:2];\
[invocation retainArguments];\
[invocation invoke];\
}\
_Pragma("clang diagnostic pop")\
} while (0)

#define USER_DEFAULT    [NSUserDefaults standardUserDefaults]
#define kAppWindow       [[UIApplication sharedApplication].delegate window]

/// 个推开发者网站中申请App时，注册的AppId、AppKey、AppSecret
#define kGtAppId           @"lU5ALdLFhNAI4VtYHXQsmA"
#define kGtAppKey          @"tLpGvXHFZC7q1VkP3IDiP8"
#define kGtAppSecret       @"hD85WfsKvwAjLeVUOk36p8"
#define kGtAppName         @"com.ios.kuajieshou(生产).p12"

#define kServerURLKey      @"ServerURLKey"
#define kAccessTokenKey    @"X-Access-Token"

/// 项目颜色
#define PORJECT_COLOR [UIColor colorWithRed:32.0/255 green:140.0/255 blue:210.0/255 alpha:1.0]
#define BG_GARY_COLOR [UIColor colorWithRed:237.0/255 green:237.0/255 blue:237.0/255 alpha:1.0]
#define LINE_COLOR [UIColor colorWithRed:230.0/255 green:230.0/255 blue:230.0/255 alpha:1.0]
#define DISABLE_COLOR [UIColor colorWithRed:187.0/255 green:187.0/255 blue:187.0/255 alpha:1.0]

#endif /* Const_h */
